<div id="ell">
<el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="姓名">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
    
  <el-form-item label="年龄">
    <el-input-number v-model="form.age" :min="10" :max="60" label="年龄大于18小于60"></el-input-number>
  </el-form-item>
  
  
  <el-form-item>
    <el-button type="primary" @click="onSubmit">添加</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>
</div>

<script>
$(document).ready(function(){
    new Vue({
        el:"#ell",
        data() {
      return {
        form: {
          name: '',
          age:20
        }
      }
    },
    methods: {
      onSubmit() {
        var self = this;
        $.post("/admin/index/add",this.form, function(res){
            //console.log(res)
            if(res.messages.length>0) {
                const h = self.$createElement;
                var message = h("ul", null, res.messages.map(function(v){
                    return h("li",null,v)    
                }))
                
                self.$alert(message, '错误提示', {
                    confirmButtonText: '确定'
                });   
            }    
        },"json")
      }
    }  
    })
})
</script>

<style>
.line {text-align: center}
</style>

